﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using University.Workshop.DataAccess;
using System.Collections.ObjectModel;
namespace University.Workshop.Business
{
    public class ContactsManager
    {
        public Collection<UserContacts> PendingSend{get;private set;}
        public Collection<UserContacts> PendingReceive { get; private set; }
        public Collection<UserContacts> Friends { get; private set; }
        public Collection<UserContacts> All{get;private set;}

        public ContactsManager()
        {
            PendingReceive = new Collection<UserContacts>();
            PendingSend = new Collection<UserContacts>();
            Friends = new Collection<UserContacts>();
            All = new Collection<UserContacts>();
        }
        public void SetAll(Collection<UserContacts> copy)
        {
            if (copy != null)
            {
                All.Clear();
                foreach (UserContacts userReceived in copy)
                {
                    All.Add(userReceived);
                }
            }
        }
        public bool Separate(string user) //MODIFIED PROBAR
        {
            if (!string.IsNullOrEmpty(user))
            {
                foreach (UserContacts contact in All)
                {
                    if (contact.Status == "Friends")
                    {

                        Friends.Add(contact);
                    }
                    if (contact.Status == "Pending")
                    {
                        if (contact.UserName == user)
                            PendingSend.Add(contact);
                        else
                            PendingReceive.Add(contact);
                    }
                }

                return true;
            }

            return false;
            
        }
    }
}
